package com.example.hospital.mis.controller.form.user;

import lombok.Data;
import com.example.hospital.constant.UserConstants;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Data
public class LoginForm {
  
  @NotBlank(message = "用户名不能为空")
  @Length(min = UserConstants.USERNAME_MIN_LENGTH, max = UserConstants.USERNAME_MAX_LENGTH, message = "用户名长度限制为" + UserConstants.USERNAME_MIN_LENGTH + "~" + UserConstants.USERNAME_MAX_LENGTH + "位")
  @Pattern(regexp = "^[a-zA-Z0-9]{" + UserConstants.USERNAME_MIN_LENGTH + "," + UserConstants.USERNAME_MAX_LENGTH + "}$", message = "password内容不正确")
  private String username;
  
  @NotBlank(message = "密码不能为空")
  @Length(min = UserConstants.PASSWORD_MIN_LENGTH, max = UserConstants.PASSWORD_MAX_LENGTH, message = "密码长度限制为" + UserConstants.PASSWORD_MIN_LENGTH + "~" + UserConstants.PASSWORD_MAX_LENGTH + "位")
  @Pattern(regexp = "^[\\p{P}A-Za-z0-9]{" + UserConstants.PASSWORD_MIN_LENGTH + "," + UserConstants.PASSWORD_MAX_LENGTH + "}$", message = "password内容不正确")
  private String password;
}
